<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .btn{
            width: 100px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            background-color: #cdcdcd;
            border-radius: 20px;
        }
        .btn-error{
            background-color: red;
        }

    </style>

</head>
<body>
    <div id="app">
        <div :class="myclass">样式</div>
        <div   class="btn" :class="{'btn-error':flag}">样式</div>
        <div :class="[myclass,myclass1]">样式</div>
        <button @click="updateClass">修改样式</button>
    </div> 
</body>
<script>
    new  Vue({
        el:"#app",
        data:{
            flag:false,
            myclass:"btn",
            myclass1:"btn-error"
        },
        methods:{
            updateClass(){
                this.myclass = "btn btn-error",
                this.flag= true;
            }
        }
    })


</script>
</html>